package com.alibaba.provider;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.serializers.MapSerializer;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by SunLei on 2016/2/22.
 */
public class KryoMapTest {
    public static void main(String[] args) throws Exception{
        Kryo kryo=new Kryo();
        MapSerializer mapSerializer=new MapSerializer();
//        mapSerializer.setKeyClass(String.class,kryo.getSerializer(String.class));
//        mapSerializer.setValueClass(String.class,kryo.getSerializer(String.class));
//        kryo.register(HashMap.class,mapSerializer);
        Output output=new Output(new FileOutputStream("D:/a"));
        Map<String,String> m=new HashMap<String,String>();
        kryo.writeObject(output,m);
        output.close();

        Input input=new Input(new FileInputStream("D:/a"));
        Map<String,String> aa=kryo.readObject(input,Map.class);
        input.close();
    }

}
